package com.scpii.universal.struts.manage;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.doone.comm.paginaction.Pagination;
import com.scpii.universal.action.BaseAction;
import com.scpii.universal.constant.GenericConstants;
import com.scpii.universal.dto.CommentManageDto;
import com.scpii.universal.service.CommentManageService;

/**
 * 
 * universalWeb
 * 
 * @author zhangqiang 2012-7-26下午03:26:12
 */
@Controller
@Scope("prototype")
public class CommentManageAction extends BaseAction {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -3182172519118621756L;
	@Resource
	private CommentManageService commentManageService;

	// 分页信息
	private Pagination page = new Pagination();

	// 查詢條件
	private CommentManageDto condition;
	// 評論列表
	private List<CommentManageDto> commentList;
	//評論主键ID
	private Integer intCommentId;
	/**
	 * 获取评论信息
	 * 
	 * @return
	 * @author zhangqiang 2012-7-26下午03:24:42
	 */

	public String getCommentInfo() {
		// 判断第一次进入分页信息
		if (getSelectPerPage("page") == -1) {
			page.setPageRecord(GenericConstants.PAGE_NO);
		} else {
			page.setPageRecord(getSelectPerPage("page"));
		}
		// 判断是否是第一次查询
		if (getQueryFlag("page") == -1) {
			page.setTotalRecord(commentManageService.getCountByCondition(
					getUserInfo().getAppId(), condition));
		} else {
			page.setTotalRecord(getQueryFlag("page"));
		}
		setPageParameters(page, "page");
		commentList = commentManageService.getCommentInfo(getUserInfo()
				.getAppId(), condition, page.getCurrentPage(), page.getPageRecord());
		return SUCCESS;
	}
	/**
	 * 删除评论
	 * @return
	 * @author zhangqiang
	 * 2012-7-26下午04:10:35
	 */
	public String delCommentById(){
		commentManageService.updateCommentById(intCommentId);
		return SUCCESS;
	}

	public List<CommentManageDto> getCommentList() {
		return commentList;
	}

	public void setCommentList(List<CommentManageDto> commentList) {
		this.commentList = commentList;
	}

	public Pagination getPage() {
		return page;
	}

	public void setPage(Pagination page) {
		this.page = page;
	}

	public CommentManageDto getCondition() {
		return condition;
	}

	public void setCondition(CommentManageDto condition) {
		this.condition = condition;
	}
	public Integer getIntCommentId() {
		return intCommentId;
	}
	public void setIntCommentId(Integer intCommentId) {
		this.intCommentId = intCommentId;
	}

}
